package cn.kgc.web;

import cn.kgc.entity.Product;
import cn.kgc.service.ProductService;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/product")
public class ProductController {
    //准备日志记录器
    //private Logger log = Logger.getLogger(ProductController.class);

    @Autowired
    private ProductService productService;

    @GetMapping("/list")
    public PageInfo<Product> showProductList(String productName,
                                              @RequestParam(defaultValue = "1") Integer pageId){
         log.debug("服务提供方执行分页查询:商品名称查询条件为："+productName+",页码为："+pageId);
         return productService.queryProductList(productName,pageId);
    }

}
